/* Version 0.01 2012.06.27  */

#include "button.h"

Button::Button(float _x, float _y, int _w, int _h, int _marginX, int _marginY, LPTSTR _text,unsigned int _id)
:Displayable(_x, _y, _w, _h),  marginX(_marginX), marginY(_marginY) ,text(_text), bInArea(FALSE), id(_id)
{
	bCheck = TRUE;
	bClick = TRUE;
}

void Button::checkArea(float mx, float my)
{
	if(isInArea(mx,my))
		bInArea = TRUE;
	else
		bInArea = FALSE;
}


int Button::beClicked()
{
	return id;
}

void Button::draw(HDC hdc)
{
	
	Displayable::draw(hdc);
	if(bInArea)
		Rectangle(hdc, x+2, y+2, x+w-2, y+h-2);
	TextOut(hdc, x+marginX, y+marginY, text.c_str(), text.size());
}